﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataLib.Common;
using System.Data;
using Microsoft.Reporting.WebForms;
using Ewts.Code;

namespace Ewts.RDLC
{
    public partial class tallyCollectSltRDLC : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //归属地
                ListItem item = new ListItem();
                item.Text = "--请选择--";
                item.Value = "";
                DataLib.BLL.City bllLib = new DataLib.BLL.City();
                ddlbelong.DataSource = bllLib.GetList(" flag1 ='01'");
                ddlbelong.DataTextField = "cityname";
                ddlbelong.DataValueField = "cityname";
                ddlbelong.DataBind();
                ddlbelong.Items.Insert(0, item);



                // 处理地
                ddlgraphic.DataSource = bllLib.GetList(" flag1 ='02'");
                ddlgraphic.DataTextField = "cityname";
                ddlgraphic.DataValueField = "cityname";
                ddlgraphic.DataBind();
                ddlgraphic.Items.Insert(0, item);

                
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            this.tallyCollectSltReport.Visible = true;  //设置页面visible：false,点击查询后为true  2013.04.17 梁玲
            string cjo = txtCJO.Text;
            string cum = txtcum.Text;
            string insno = txtInsno.Text;
            string insstatus = ddlInsstatus.SelectedValue;
            string loadnum = txtLoadnum.Text;
            string tallystatus = ddltallyCollectSlt.SelectedValue;
            string time1 = txttime1.Text;
            string time2 = txttime2.Text;
            string belong = ddlbelong.SelectedValue;
            string graphic = ddlgraphic.SelectedValue;

            if ((!PageValidate.IsDateTime(time1) && PageValidate.IsDateTime(time2)) || ((PageValidate.IsDateTime(time1) && !PageValidate.IsDateTime(time2))))
            {
                MessageBox.Show(this, "日期格式不合法，时间段填写完整！");
                return;
            }

            this.tallyCollectSltReport.Visible = true;

            DataTable dt = new DataLib.BLL.Tally().GetTallyProc(loadnum, cum, cjo, insno, insstatus, tallystatus, time1, time2,belong,graphic);
            
            ReportDataSource rds = new ReportDataSource("tallyCollectSltDS", dt);
            tallyCollectSltReport.LocalReport.DataSources.Clear();
            tallyCollectSltReport.LocalReport.DataSources.Add(rds);
            new RDLCPrinter().FillRow(dt, 3, 20, 20);
            tallyCollectSltReport.LocalReport.Refresh();

        }
    }
}